package com.ict.ms.trackPlayBack.facade.common;

import java.util.ArrayList;
import java.util.Arrays;

public class test {
    public static void main(String[] args){

        //跨越180
        Double[] point_x = {170.0,-170.0,-170.0,170.0,170.0};
        Double[] point_y = {5.0,5.0,3.0,3.0,5.0};

        ArrayList<Double> point_x_list = new ArrayList<Double>(Arrays.asList(point_x));
        ArrayList<Double> point_y_list = new ArrayList<Double>(Arrays.asList(point_y));

        PolygonWithLongitudeCrossed180 p = new PolygonWithLongitudeCrossed180(point_x_list,point_y_list);


        //判断是否在内
        double[] pointToTest_x = {-165,-175,175,165};
        for (double x: pointToTest_x
                ) {
            boolean isOk = p.containsPoint(x,4.0);
            System.out.println(String.format("<%f,%f> in <(170, 5),(-170, 5),(-170, 3),(170, 3)>:%s",x,4.0,isOk));

        }

        //正常
        Double[] point_x2 = {170.0,150.0,150.0,170.0,170.0};
        Double[] point_y2 = {5.0,5.0,3.0,3.0,5.0};

        ArrayList<Double> point_x_list2 = new ArrayList<Double>(Arrays.asList(point_x2));
        ArrayList<Double> point_y_list2 = new ArrayList<Double>(Arrays.asList(point_y2));

        PolygonWithLongitudeCrossed180 p2 = new PolygonWithLongitudeCrossed180(point_x_list2,point_y_list2);


        //判断是否在内
        double[] pointToTest_x2 = {140,155,160,175};
        for (double x: pointToTest_x2
                ) {
            boolean isOk = p2.containsPoint(x,4.0);
            System.out.println(String.format("<%f,%f> in <(170, 5),(150, 5),(150, 3),(170, 3)>:%s",x,4.0,isOk));

        }
    }
}
